test: add property-based tests with FsCheck#93
Merged
Conversation
Add FirstClassErrors.PropertyTests, an FsCheck-based project that exercises the core value objects and result type with randomly generated input: - ErrorCode: verbatim round-trip through ToString and the implicit string conversion, ordinal equality, and rejection of blank or null codes. - ErrorDescription: trimming, idempotent normalization, blank-detail collapse, and rejection of blank or null mandatory messages. - Outcome<T>: the monad laws (left and right identity, associativity), reference propagation of the original error on failure, To/Then consistency, and the Recover and Finally semantics. The bare `using FsCheck;` also gives OpenSSF Scorecard a C# property-based fuzzing signal for its Fuzzing check. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg
Record why FirstClassErrors.PropertyTests exists from a Scorecard standpoint and the tooling-version caveat: C# property-based detection (FsCheck) landed in scorecard v5.5.0, while [email protected] still bundles v5.3.0, so the Fuzzing sub-check only turns green once the scan runs on >= v5.5.0. Kept in sync across the English and French maintainer notes. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a new
FirstClassErrors.PropertyTestsproject containing property-based tests using FsCheck. These tests verify the monad laws forOutcome<T>, validate invariants ofErrorCodeandErrorDescription, and exercise the library's validating factories with fuzzing-style inputs. This satisfies Scorecard's Fuzzing check and provides richer behavioral coverage than hand-written examples alone.Type of change
Changes
FirstClassErrors.PropertyTestsproject targeting .NET 10.0 with FsCheck 3.3.3OutcomeMonadLawTests: property-based verification of left identity, right identity, associativity, functor identity, and error propagation by reference identityErrorCodePropertyTests: verification that error codes round-trip through string conversions, equality is ordinal, and blank/null codes are rejectedErrorDescriptionPropertyTests: verification of message trimming, normalization idempotence, blank message handling, and validation of mandatory fieldsPropertyTestSupport.cswith custom FsCheck generators (NonBlank(),Blank()) and assertion helpers (Expect.Throws<T>()) for fuzzing-style inputsFirstClassErrors.slnto include the new test projectmaintainers/workflows/scorecard.en.mdandmaintainers/workflows/scorecard.fr.mdto document the Fuzzing check implementation and version constraintsTesting
dotnet build FirstClassErrors.slndotnet test FirstClassErrors.slnDocumentation
Related issues
https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg